package com.nbjtjc.safe.api.report;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.nbjtjc.safe.annotation.SysLog;
import com.nbjtjc.safe.service.report.CostReportService;

@RestController
@RequestMapping("/report/cost")
@CrossOrigin("*")
public class CostReportController {
	@Autowired
	private CostReportService costReportService;
	
	@SysLog("下载受伤人员获赔记录表")
	@GetMapping(value = "/costInjuryClaimExcel/{year}")
	public void record(@PathVariable("year") String year, HttpServletResponse response){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
		Date yeard;
		try {
			yeard = sdf.parse(year);
			costReportService.costInjuryClaimExcel(response, yeard);

		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	
	@SysLog("下载安全生产投入预算计划表")
	@GetMapping(value = "/costBudgetPlanExcel/{year}")
	public void budgetPlan(@PathVariable("year") String year, HttpServletResponse response){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
		Date yeard;
		try {
			yeard = sdf.parse(year);
			costReportService.costBudgetPlanExcel(response, yeard);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@SysLog("下载安全生产费用投入登记表")
	@GetMapping(value = "/costAccountRecExcel/{year}")
	public void accountRec(@PathVariable("year") String year, HttpServletResponse response){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
		Date yeard;
		try {
			yeard = sdf.parse(year);
			costReportService.costAccountRecExcel(response, yeard);

		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
	}
	
	@SysLog("下载安全生产投入预算执行情况表")
	@GetMapping(value = "/costBudgetImplExcel/{year}")
	public void costBudgetImplExcel(@PathVariable("year") String year, HttpServletResponse response){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
		Date yeard;
		try {
			yeard = sdf .parse(year);
			costReportService.costBudgetImplExcel(response, yeard);

		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	
}
